﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/BMP_EditII.master"
    ResponseEncoding="utf-8" AutoEventWireup="true" CodeFile="Edit.aspx.cs" Inherits="Pages_Equip_Installed_Edit" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="contentPlaceHolder" runat="Server">
    <table class="editTable" id="editTable" cellpadding="0" cellspacing="0">
        <tr>
            <th>
                设备内SIM卡号(<label style="color: Red">*</label>)
            </th>
            <td>
                <input id="Equip_InstalledInfo_Equip_SimNo" type="text" des="设备内SIM卡号" emp="true"
                    runat="server" clientidmode="Static" />
            </td>
            <th>
                市(<label style="color: Red">*</label>)
            </th>
            <td>
            <asp:HiddenField ID="hidCity" runat="server" clientidmode="Static"  />
                <select name="province" id="province" style="display: none">
                </select>
                <select name="city" id="city" name="city" opt="%" field="Equip_City" onchange="SetPC('city');"
                    style="width: 100px;">
                </select>
                <input id="Equip_InstalledInfo_Equip_City" type="text" des="市" emp="true" runat="server"
                    clientidmode="Static" style="display: none;" />
            </td>
            <th>
                县（区）(<label style="color: Red">*</label>)
            </th>
            <td>
                <select name="district" id="district" opt="%" field="Equit_Country" onchange="SetPC('district');"
                    style="width: 100px; margin-right: 5px;">
                </select>
                <input id="Equip_InstalledInfo_Equip_County" type="text" des="县（区）" emp="true" runat="server"
                    style="display: none;" clientidmode="Static" />
            </td>
        </tr>
        <tr>
            <th>
                乡（镇、社区）(<label style="color: Red">*</label>)
            </th>
            <td>
                <input id="Equip_InstalledInfo_Equip_Town" type="text" des="乡（镇、社区）" emp="true" runat="server"
                    clientidmode="Static" />
            </td>
            <th>
                村（街道、单位）(<label style="color: Red">*</label>)
            </th>
            <td>
                <input id="Equip_InstalledInfo_Equip_Village" type="text" des="村（街道、单位）" emp="true"
                    runat="server" clientidmode="Static" />
            </td>
            <th>
                <input type="button" id="btnGetLongLa" value="获取经纬度" style="width: 100px !important"
                    onclick="GetLongLaInfo();" />
                经度(<label style="color: Red">*</label>)
            </th>
            <td>
                <input id="Equip_InstalledInfo_Equip_Longitude" type="text" des="经度" emp="true" exp="reg_Decimal"
                    runat="server" clientidmode="Static" />
            </td>
        </tr>
        <tr>
            <th>
                纬度(<label style="color: Red">*</label>)
            </th>
            <td>
                <input id="Equip_InstalledInfo_Equip_Latitude" type="text" des="纬度" emp="true" exp="reg_Decimal"
                    runat="server" clientidmode="Static" />
            </td>
            <th>
                类型(<label style="color: Red">*</label>)
            </th>
            <td>
                <asp:DropDownList ID="Equip_InstalledInfo_Equip_Class" runat="server" Width="160px"
                    des="类型" emp="true" ClientIDMode="Static">
                </asp:DropDownList>
            </td>
            <th>
                发送方式(<label style="color: Red">*</label>)
            </th>
            <td>
                <asp:DropDownList ID="Equip_InstalledInfo_Equip_SendMode" runat="server" Width="160px"
                    des="发送方式" emp="true" ClientIDMode="Static">
                </asp:DropDownList>
            </td>
        </tr>
        <tr>
            <th>
                安装时间(<label style="color: Red">*</label>)
            </th>
            <td>
                <input id="Equip_InstalledInfo_Equip_InstallDate" type="text" onclick="WdatePicker();"
                    des="安装时间" emp="true"  runat="server" clientidmode="Static" />
            </td>
            <th>
                设备厂家(<label style="color: Red">*</label>)
            </th>
            <td>
                <asp:DropDownList ID="Equip_InstalledInfo_Factory_No" runat="server" Width="160px"
                    des="设备厂家编号" emp="true" ClientIDMode="Static">
                </asp:DropDownList>
            </td>
            <th>
                备注
            </th>
            <td>
                <textarea id="Equip_InstalledInfo_Ext" type="text" rows="2" des="评论内容" runat="server"
                    title="备注" clientidmode="Static" /></textarea>
            </td>
        </tr>
    </table>
    <script type="text/javascript" src="<%= ZPath.ResourcesURI %>Scripts/jQuery/jquery.js"></script>
    <script type="text/javascript" src="<%= ZPath.ResourcesURI %>Scripts/CitySelect.js"></script>
    <link rel="stylesheet" href="<%= ZPath.StylesURI %>Global.css" type="text/css" media="screen" />
    <script type="text/javascript">
        //省市区联动
        if (CitySel != undefined) {
            CitySel.init('province', 'city', 'district');
        }
        //初始化
        CitySel.loadC();
        CitySel._ed.html('');
        jsSelectItemByValue(document.getElementById('city'), document.getElementById('Equip_InstalledInfo_Equip_City').value);

       

         CitySel.loadD();
        jsSelectItemByValue(document.getElementById('district'), document.getElementById('Equip_InstalledInfo_Equip_County').value);

       // if (document.getElementById('Equip_InstalledInfo_Equip_SimNo').value=='') {
        var words = document.getElementById('hidCity').value;
        if (words != '') {
            var objSelect = document.getElementById('city');
            for (var i = 0; i < objSelect.options.length; i++) {
                //alert(objSelect.options[i].text + " :  " + words + "   " + objSelect.options[i].text.indexOf(words));
                //if (objSelect.options[i].text.indexOf(words) == -1) {
                if (words.indexOf(objSelect.options[i].text) == -1) {
                    //objSelect.options[i].selected = true;
                    objSelect.remove(i);
                    i = i - 1;
                }
                SetPC("city");
                CitySel.loadD();
            } 
        }
      //  }
        
    

        //设置省市区值
        function SetPC(change) {
            //alert(value);
            //tc:txt
            var tc = document.getElementById('Equip_InstalledInfo_Equip_City');
            var td = document.getElementById('Equip_InstalledInfo_Equip_County');
            var sc = document.getElementById('city');
            var sd = document.getElementById('district');
            var scText = "";
            var sdText = "";
            if (change == "city") {
                //选中的市，初始化市、区
                tc.value = "";
                td.value = "";
                if (sc != undefined && sc.selectedIndex != -1) {
                    scText = sc.options[sc.selectedIndex].text;
                    if (scText != undefined && scText != '===市===') {
                        tc.value = scText;
                    }
                }
            }

            if (change == "district") {
                td.value = "";
                if (sd != undefined && sd.selectedIndex != -1) {
                    sdText = sd.options[sd.selectedIndex].text;
                    if (sdText != undefined && sdText != '===区===') {
                        td.value = sdText;
                    }
                }
            }
        }

        //设置select中text="paraText"的第一个Item为选中 
        function jsSelectItemByValue(objSelect, objItemText) {
            for (var i = 0; i < objSelect.options.length; i++) {
                if (objSelect.options[i].text == objItemText) {
                    objSelect.options[i].selected = true;
                    break;
                }
            }
        }

        function GetLongLaInfo() {
            var city = $("#Equip_InstalledInfo_Equip_City").val();
            var country = $("#Equip_InstalledInfo_Equip_County").val();
            var name = $("#Equip_InstalledInfo_Equip_Village").val();

            if (city == undefined || city == "") {
                alert("请选择市！");
                $("#Equip_InstalledInfo_Equip_City")[0].focus();
                return;
            }
            if (country == undefined || country == "") {
                alert("请选择县（区）！");
                $("#Equip_InstalledInfo_Equip_County")[0].focus();
                return;
            }
            if (name == undefined || name == "") {
                alert("请录入村（街道、单位）！");
                $("#Equip_InstalledInfo_Equip_Village")[0].focus();
                return;
            }

            $.ajax({
                type: "POST",
                async: false,
                contentType: "application/json;charset=utf-8",
                url: "GetLongLa.ashx?action=GetLongLa&name=" + encodeURIComponent(name) + "&country=" + encodeURIComponent(country) + "&city=" + encodeURIComponent(city),
                success: function (msg) {
                    if (msg == undefined || msg == "" || msg == ",") {
                        alert("未找到坐标，请检查地区录入是否正确！");
                        $("#Equip_InstalledInfo_Equip_Longitude").val("");
                        //$("#Equip_InstalledInfo_Equip_Longitude").attr("disabled", false);
                        //$("#Equip_InstalledInfo_Equip_Longitude").attr("update", false);
                        $("#Equip_InstalledInfo_Equip_Latitude").val("");
                        // $("#Equip_InstalledInfo_Equip_Latitude").attr("disabled", false);
                        // $("#Equip_InstalledInfo_Equip_Latitude").attr("update", false);
                    } else {
                        var words = msg.split(',')
                        $("#Equip_InstalledInfo_Equip_Longitude").val(words[0]);
                        //$("#Equip_InstalledInfo_Equip_Longitude").attr("disabled", "disabled");
                        //$("#Equip_InstalledInfo_Equip_Longitude").attr("update", true);
                        $("#Equip_InstalledInfo_Equip_Latitude").val(words[1]);
                        //$("#Equip_InstalledInfo_Equip_Latitude").attr("disabled", "disabled");
                        //$("#Equip_InstalledInfo_Equip_Latitude").attr("update", true);
                        alert("获取成功！");
                    }
                }
            });
        }



    </script>
</asp:Content>
